package com.tanhua.autoconfig;

import com.tanhua.autoconfig.properties.*;
import com.tanhua.autoconfig.template.*;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author げっしょく
 * @date 2021/10/21
 */

@EnableConfigurationProperties(
        {SmsProperties.class,
         OssProperties.class,
         FaceProperties.class,
        HuanXinProperties.class,
        GreenProperties.class}
)
public class TanhuaAutoConfiguration {

    @Bean
    public SendSmsTemplate sendSms(SmsProperties smsProperties) {
        return new SendSmsTemplate(smsProperties);
    }

    @Bean
    public OssTemplate uplocal(OssProperties properties) {
        return new OssTemplate(properties);
    }

    @Bean
    public FaceTemplate template() {
        return new FaceTemplate();
    }

    @Bean
    public HuanXinTemplate huanXinTemplate(HuanXinProperties huanXinProperties) {
        return new HuanXinTemplate(huanXinProperties);
    }

    @Bean
    @ConditionalOnProperty(prefix = "tanhua.green",value = "enable", havingValue = "true")
    public AliyunGreenTemplate aliyunGreenTemplate(GreenProperties properties) {
        return new AliyunGreenTemplate(properties);
    }
}
